namespace RuthlessConquest {
    public static class Crc32 {
        public static uint[] Table;

        static Crc32() {
            uint num = 3988292384u;
            Table = new uint[256];
            for (uint num2 = 0u; num2 < Table.Length; num2++) {
                uint num3 = num2;
                for (int num4 = 8; num4 > 0; num4--) {
                    num3 = (num3 & 1) != 1 ? num3 >> 1 : (num3 >> 1) ^ num;
                }
                Table[num2] = num3;
            }
        }

        public static uint ComputeChecksum(byte[] bytes) {
            uint num = uint.MaxValue;
            for (int i = 0; i < bytes.Length; i++) {
                byte b = (byte)((num & 0xFF) ^ bytes[i]);
                num = (num >> 8) ^ Table[b];
            }
            return ~num;
        }
    }
}